package com.kiln.juxingqs.adapter

import android.content.Context
import android.content.Intent
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import androidx.recyclerview.widget.RecyclerView
import client.global.commlib.base.BaseLoadmoreAdapter
import client.global.commlib.base.BindingViewHoder
import com.kiln.juxingqs.R
import com.kiln.juxingqs.api.bean.GetPpRet
import com.kiln.juxingqs.databinding.LayoutProfitandlosstemBinding
import com.kiln.juxingqs.ui.ApplyThActivity

class ProfitAndLossAdapter : BaseLoadmoreAdapter<GetPpRet.Deal> {

    constructor(context: Context) : super(context) {

    }

    override fun createVh(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
        return BindingViewHoder(
            DataBindingUtil.inflate(
                layoutInflater,
                R.layout.layout_profitandlosstem,
                parent,
                false
            )
        )
    }

    override fun bindVh(holder: RecyclerView.ViewHolder, position: Int) {
        val bindingViewHolder = holder as BindingViewHoder<ViewDataBinding>
        val binding = bindingViewHolder.binding as LayoutProfitandlosstemBinding
        val bean = getItem(position)
        binding.bean = bean
        binding.event = this
    }

    fun goTIhuo(bean: GetPpRet.Deal) {
        context.startActivity(Intent(context, ApplyThActivity::class.java).apply {
            putExtra("bean", bean)
        })
    }
}